<template>
	<om-page :title="pageTitle">
		<om-topbutton :hasBgColor="true" placeHolder="请输入" @click='searchTab'></om-topbutton>
		<view style="height: 50px;"></view>
		<view v-for="(item, index) in wxMenuList" :key="index">
			<view v-if="item.menu && item.menu.length">
				<uni-card style="border: none;border-radius: 1px;" :titleUnderline="false" :is-full="true" :title="item.groupName">
					<om-menu :menuList="item.menu" :colLen="5" :bordered="false" fontSize="small"></om-menu>
				</uni-card>
				<view style="height: 1px" class="bg-gray"></view>
			</view>
		</view>
	</om-page>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: "更多工具",
				wxMenuList: []
			}
		},
		watch:{
			
		},
		methods: {
			workHourCanConfirm(){
				let _that = this
				_that.om.request(
					"attendConfirm/canConfirm"
				).then(res=>{
					for(let item of _that.wxMenuList) {
						for(let menu of item.menu){
							if(menu.h5url === "/pages/mine/workhour/workhour"){
								_that.$set(menu,"showDot",res.value)
							}
						}
					}
				})
			},
			salarybillCanConfirm(){
				let _that = this
				_that.om.request(
					"salaryConfirm/canConfirm"
				).then(res=>{
					for(let item of _that.wxMenuList){
						for(let menu of item.menu){
							if(menu.h5url === "/pages/mine/salaryroll/salaryroll"){
								_that.$set(menu,"showDot",res.value)
							}
						}
					}
				})
			},
			searchTab() {
				uni.navigateTo({
					url: "search"
				});
			},
			loadMenu() {
				let _that = this
				_that.om.request('wxCommon/getMenu').then(res => {
					if (res.succeed) {
						// _that.wxMenuList = res.value;
						var menuArr = [];
						var arr = [];
						for(var i=0;i<res.value.length;i++){
							let group = res.value[i]
							if(group.groupName != "我的" && group.groupName != "查询"){
								menuArr.push(group) 
								for(var j=0;j<group.menu.length;j++){
									let m = group.menu[j]
									arr.push(m)
								}
							}
						}
						_that.wxMenuList = menuArr;
						uni.setStorage({
							key: 'menu_cache',
							data:arr
						})
						this.workHourCanConfirm()
						this.salarybillCanConfirm()
					}
				})
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title: this.pageTitle
			})
			this.loadMenu()
		},
		onShow() {
			this.workHourCanConfirm()
			this.salarybillCanConfirm()
		}
	}
</script>

<style>
	
</style>
